package com.studerb.events;

import java.util.EventObject;

import com.studerb.tasks.interfaces.ITask;
import com.studerb.tasks.interfaces.ITaskListener;

/**
 * An encapsulation of the value produced one of the {@code Task} execution
 * methods: {@code doInBackground()}, {@code process}, {@code done}. The source
 * of a {@code TaskEvent} is the {@code Task} that produced the value.
 * 
 * @see ITaskListener
 * @see Task
 */
public class TaskEvent<T> extends EventObject {
    private final T value;

    /**
     * Construct a {@code TaskEvent}.
     * 
     * @param source the {@code Task} that produced the value.
     * @param value the value, null if type {@code T} is {@code Void}.
     */
    public TaskEvent(ITask source, T value) {
        super(source);
        this.value = value;
    }

    /**
     * Returns the value this event represents. 
     *
     * @return the {@code value} constructor argument.
     */
    public final T getValue() {
        return value;
    }
}
